import { request } from "@/plugins/request";

// 获取公共的文章列表
export const getArticles = params => {
    return request({
        method: "GET",
        url: "/api/articles",
        params
    })
}

// 获取关注的文章列表
export const getFeedArticles = params => {
    return request({
        method: 'GET',
        url: '/api/articles/feed',
        params,
        //在请求拦截器里设置token
    })
}

// 添加点赞
export const addFavorite = slug => {
    return request({
        method: "POST",
        url: `/api/articles/${slug}/favorite`,
        params
    })
}
// 添加点赞
export const deleteFavorite = slug => {
    return request({
        method: "DELETE",
        url: `/api/articles/${slug}/favorite`,
        params
    })
}
// 获取文章详情
export const getArticle = slug => {
    return request({
        method: "GET",
        url: `/api/articles/${slug}`,
        params
    })
}
// 获取文章评论
export const getComments = slug => {
    return request({
        method: "GET",
        url: `/api/articles/${slug}/comments`,
        params
    })
}